package com.zch.work.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zch.domain.Result;
import com.zch.entity.TbOperate;
import com.zch.work.service.TbOperateService;
import com.zch.work.mapper.TbOperateMapper;
import com.zch.work.vo.DeletedVo;
import com.zch.work.vo.OperateVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
* @author 28763
* @description 针对表【tb_operate(操作内容维护表
)】的数据库操作Service实现
* @createDate 2023-10-30 19:57:14
*/
@Service
public class TbOperateServiceImpl extends ServiceImpl<TbOperateMapper, TbOperate>
    implements TbOperateService{

    @Autowired
    TbOperateMapper tbOperateMapper;

    @Override
    public Result deletedByID(DeletedVo deletedVo) {

        TbOperate tbOperate = new TbOperate();
        tbOperate.setId(deletedVo.getId());
        tbOperate.setDeleted(1);
        boolean b = updateById(tbOperate);
        return b?Result.SUCCESS():Result.FAILED(201,"删除失败");
    }

    @Override
    public Result addOperate(TbOperate tbOperate) {
        boolean b = save(tbOperate);
        return b?Result.SUCCESS():Result.FAILED(201,"添加失败");

    }

    @Override
    public Result updateAll(TbOperate tbOperate) {
        boolean b = updateById(tbOperate);
        return b?Result.SUCCESS():Result.FAILED(201,"修改失败");
    }

    @Override
    public Result selectByEligibility(OperateVo operateVo) {
        Page<TbOperate> tbOperatePage = new Page<>(operateVo.getPageNum(), operateVo.getPageSize());
        Page<TbOperate> page = tbOperateMapper.selectByEligibility(tbOperatePage,operateVo);
        return Result.SUCCESS(page);
    }
}




